// 创建路由实例

// 导入 路由实例方法 
import {
    createRouter , 
    createWebHistory ,
    createWebHashHistory,
    }
from "vue-router";


// 定义路由与组件的映射关系
const routes = [
   {
       path:"/",
       redirect:"/goods",
    },
    {
       path:"/goods",
       id:1001,
       name:"goods",
       component:() => import("./goods.vue"),  // 动态引入组件

       children: [
        {
          path: "detail",
          name:"detail",
          component: () => import("./detail.vue"),
        },
      ],
   },
   {
       path:"/assess",
       id:1002,
       name:"assess",
       component:() => import("./assess.vue"),
   },
   {
       path:"/store",
       id:1003,
       name:"store",
       component:() => import("./store.vue")
   },
  {
    path:"/cart",
    name:"cart",
    component:() => import("./cart.vue")
  }

];

// 创建路由
const router = createRouter({
   history:createWebHistory(),
   routes,  // 简写形式
})

// 导出 路由
export default router;